package persistence.repository;

import persistence.PersistenceController;
import persistence.Persistent;
import util.Log;
import util.Subsystem;
import domain.message.Directory;

/**
 * repository for directories.
 *
 * @author idan
 */
public class DirectoryRepository extends Repository<Directory>
{
	/**
	 * @param persistence persistence provider to store objects.
	 * @pre 'persistence' persists objects of type 'Directory'.
	 */
	public DirectoryRepository(final PersistenceController persistence)
	{
		super(persistence) ;
	}

	/**
	 * @param name name of the new directory.
	 * @return the newly created directory.
	 * @post directory exists in the repository.
	 */
	public Directory create(final String name)
	{
		final Directory directory = new Directory(Persistent.INVALID_ID, name) ;
		this.put(directory) ;
		Log.getLogger(Subsystem.REPOSITORY).finest("directory " + directory + " created.") ;
		return directory ;
	}
}